﻿
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Collections.Generic;
using Web.Controllers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Cors;
using Stock.Core;
using Stock.Model;

namespace Web.Controllers
{
    public class LogController : BaseApiController
    {
        private ILoggerService _l;


        public LogController(ILoggerService l)
		{
            _l = l;
		}

		/// <summary>
		/// 获取mongo日志
		/// </summary>
		/// <returns>The log.</returns>
		/// <param name="date">Date.</param>
		/// <param name="executedTime">Executed time.</param>
		[HttpGet()]
        public dynamic getLog(string date, int? executedTime, string logType)
        {
            DateTime? d = DateTime.Now.AddDays(-1);
            if(!string.IsNullOrEmpty(date))
            {
                d = DateTime.Parse(date);
            }

            return _l.GetLog(d, executedTime, logType);
        }

		/// <summary>
		/// RemoveAll
		/// </summary>
		/// <returns>The all.</returns>
		[HttpPost()]
        public async Task<dynamic>  RemoveAll()
		{
             await _l.RemoveAll();
            return new BaseResult() { IsSuccess = true };
		}

    }
}
